#!/usr/bin/perl
# file: remoteps.pl

use strict;
use Net::Telnet;

=pot
use constant HOST => 'phage.cshl.org';
use constant USER => 'lstein';
use constant PASS => 'xyzzy';
=cut
use constant HOST => '127.0.0.1';
use constant USER => 'ruby';
use constant PASS => 'zizyruby';


my $telnet = Net::Telnet->new(HOST);
$telnet->login(USER, PASS);

my @lines = $telnet->cmd('ps -ef');
print @lines;

$telnet->print('ls -lF');
my ($before, $match) = $telnet->waitfor('/[$%#>]$/');
print $before;